<template>
  <section class="sign-wrapper nb-shadow">
    <el-tabs v-model="activeName">
      <div slot="bar" class="bar-tabs-wrapper">
        <el-button class="button-new-tag" type="text" @click="$router.go(-1)">返回</el-button>
        <el-button class="button-new-tag" type="text"  @click="exportData">导出</el-button>
      </div>
      <el-tab-pane label="签约单" class="handle-wrapper" name="1">
        <sign-list ref="sign"></sign-list>
      </el-tab-pane>
      <el-tab-pane label="保单" class="handle-wrapper" name="0">
        <policy-list ref="policy"></policy-list>
      </el-tab-pane>
    </el-tabs>
  </section>
</template>

<script>
  import SignList from './template/signList.vue'
  import PolicyList from './template/policyList.vue'
  import SeContent from '@/components/se-content.vue'
  import SeForm from '@/components/se-form.vue'
  import Mixin from '@/common/mixin'
  export default {
    data () {
      return {
        activeName: '1',
        signModel: {
          no: '',
          customerName: '',
          customerMobile: '',
          advisorName: '',
          reserveSource: '',
          contractNo: '',
          performanceDate: '',
          productName: ''
        },
        policyModel: {
          tradeCode: '',
          policyCode: '',
          contractCode: '',
          productName: '',
          insuranceCompanyName: '',
          thirdCompanyId: '',
          ownerName: '',
          ownerMobile: '',
          startCreateTime: '',
          endCreateTime: ''
        },
        sourceList: [{
          value: '1',
          label: '预约客户'
        }, {
          value: '2',
          label: '咨询顾问预约'
        }, {
          value: '3',
          label: '后台录入'
        }],
        policyDate: '',
        insKey: {
          value: 'id',
          label: 'companyName'
        },
        insData: []
      }
    },
    mixins: [Mixin],
    components: {
      SignList,
      PolicyList,
      SeContent,
      SeForm
    },
    methods: {
      getIns () {
        this.$store.dispatch('SELECT_INS', {param: {}}).then(res => {
          if (res.success) {
            this.insData = res.data
          }
        })
      },
      exportData () {
        if (this.activeName === '1') {
          this.download('/http/saas/marketing/exportReservation.json?data=', this.signModel)
        } else {
          this.download('/http/saas/marketing/exportPolicy.json?data=', this.policyModel)
        }
      }
    },
    mounted () {
      this.getIns()
    }
  }
</script>

<style lang="scss">
.sign-wrapper{
  background: white;
}
</style>
